﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>延保单</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script>
<script type="text/javascript" src="../js/shopSelecterNew.js"></script>
<script type="text/javascript" src="../js/find.js"></script>
<script type="text/javascript" src="../js/pagination.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/goodsSelecter.js"></script>
<script type="text/javascript" src="../js/vouchersTypeSelecter.js"></script>
<script type="text/javascript" src="../js/couponSelecterNew.js"></script>
<script type="text/javascript" src="../js/scheduleTypeSelecter.js"></script>
<script type="text/javascript" src="../js/lisenseSelecterNew.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" --> 
<script type="text/javascript" src="../js/manhuaDate.1.0.js"></script> 
<script type="text/javascript">
var _customerId = null;
var _memberId =  null;
var _carId = null;
$(function(){
	$('#makeDate').val(getToday())
	$(".check_btn").click(function(){
		
		var money = $("#Amount").val()
		var dtBegin = $("#dtBegin").val()
		var dtEnd = $("#dtEnd").val()
		var license = $("#license").val();
		if(!checkNull(license, "车牌号", null)||!checkNull(money, "延保金额", null)||!checkNull(dtBegin, "生效日期", null)||!checkNull(dtEnd, "失效日期", null)){
			return false;
		}
		
		
		art.dialog({fixed:true, lock: true,content:"确认收款完成？",icon:'question',ok: function (){
			saveInfo2()
		},cancel:true});
	})
	
	$("#shopIsChoosed").click(function(){
		if($("#shopIsChoosed").is(":checked")){
			$("#shopName").attr("disabled",false);
			$("#research").attr("disabled",false);
			
		}else{
			$("#shopName").attr("disabled",true);

		}
	});
	
	resetMemberInfo();
	resetRoomInfo()
})

function resetMemberInfo(){
	_memberId = null;
	_customerId = null;
	$("#levelName").val("")
		$("#cardNo").val("")
		$("#Memo").val("")
		$("#license").val("")
		$("#mp").val("")
		$("#carSystem").val("")
		$("#carType").val("")
		$("#dtBegin").val("");
		$("#dtEnd").val("");
}


function searchMember(){
	resetMemberInfo();
}

function searchMember(){
		
			var cardno = $("#memberCardNo").val().replace(/\s/gi,'')
			if(IsNotEmpty(cardno)){
				
				getShopMember();
			}else{
				
				resetMemberInfo();
			}	
}

function getShopMember(){//查询会员信息
	var shopId = getInputValue("shopName");
	if(IsEmpty(shopId)){
		artError("请先选择店铺")
		return false;
	}
	var memberCardNo = getInputValue("memberCardNo")
	if(IsEmpty(memberCardNo)){
		artError("请填写查询内容")
		return false;
	}
	var chooseType = $("#memberSelect").val()
	if(chooseType==1){
	var param = {'shopId':shopId,'name':memberCardNo}
	}else if(chooseType ==2) {
		var param = {'shopId':shopId,'mp':memberCardNo}
	}else if(chooseType == 3){
		var param = {'shopId':shopId,'license':memberCardNo}
	}
	 memberInfo = _findInfo("../custMember/find/license", param)
	if(IsNotEmpty(memberInfo)&&memberInfo.state==0){
		if(memberInfo.result.data.length==0){
			resetMemberInfo();
			
			alertErrorMessage("查无此客户")
		}else{
		if(memberInfo.result.data.length==1){
			
			$("#cardNo").val(_getStringOfJson(0, memberInfo, "CustomerName"));
			$("#mp").val(_getStringOfJson(0, memberInfo, "mp"));
		$("#levelName").val(_getStringOfJson(0, memberInfo, "levelName"))
		$("#customerName").val(_getStringOfJson(0, memberInfo, "CustomerName"))
		$("#license").val(_getStringOfJson(0, memberInfo, "License"))
		$("#carType").val(_getStringOfJson(0, memberInfo, "CarTypeName"))
		$("#carSystem").val(_getStringOfJson(0, memberInfo, "CarSystemName"))
		_memberId = _getStringOfJson(0, memberInfo, "MemberID")
			_carId = _getStringOfJson(0, memberInfo, "id")
		_customerId = _getStringOfJson(0, memberInfo, "CustomerID")
		}else{
			loadmember(memberInfo)
		}	
		
		}		
	}
	
	$("#memberCardNo").val("");
}

function loadmember(memberInfo){
		$("#memberList").empty()
	for ( var i = 0; i < memberInfo.result.data.length; i++) {
		var htm="<tr>"
			htm+="<td>"+_getStringOfJson(i, memberInfo, "customerName")+"</td>"
			htm+="<td>"+_getStringOfJson(i, memberInfo, "mp")+"</td>"
			htm+="<td>"+_getStringOfJson(i, memberInfo, "license")+"</td>"
			htm+="<td><input type=\"button\"  value=\"选择\" class=\"common_btn\" onclick=\"chooseMember('"+_getStringOfJson(i, memberInfo, "id")+"')\" ></td>"
			htm+="</tr>"
			$("#memberList").append(htm)
	}
	addMargin($("#memberDiv"))
	$("#memberDiv,#yinying1").show();
	
}
function chooseMember(id){
	for ( var i = 0; i < memberInfo.result.data.length; i++) {
		var ids = _getStringOfJson(i, memberInfo, "id")
		
		if(id==ids){
			$("#cardNo").val(_getStringOfJson(i, memberInfo, "CustomerName"));
			$("#mp").val(_getStringOfJson(i, memberInfo, "mp"));
			$("#levelName").val(_getStringOfJson(i, memberInfo, "levelName"))
			$("#license").val(_getStringOfJson(i, memberInfo, "license"))
			$("#carType").val(_getStringOfJson(i, memberInfo, "CarTypeName"))
			$("#carSystem").val(_getStringOfJson(i, memberInfo, "CarSystemName"))
			_carId = _getStringOfJson(i, memberInfo, "id")
			_memberId = _getStringOfJson(i, memberInfo, "MemberID")
			_customerId = _getStringOfJson(i, memberInfo, "CustomerID")
		}
	}
	$("#memberDiv,#yinying1").hide();

}

function saveInfo2(){
	var shopId = getInputValue("shopName");
	var roomNo = getInputValue("license");
	var Amount = getInputValue("Amount");
	var dtBegin = getInputValue("dtBegin");
	var dtEnd = getInputValue("dtEnd");
	var memo = getInputValue("Memo");
	if(IsEmpty(_memberId)){
		_memberId = null;
	}
	var heads = new Array("shopId","memberId","customerId","status","dtEnd","dtBegin","money","license","memo","carId")
	var datas = new Array(shopId,_memberId,_customerId,0,dtEnd,dtBegin,Amount,roomNo,memo,_carId)
	var jsonDate= _getJsonParseInsertStr(heads, datas);
	if(IsNotEmpty(roomNo)){
			 m = _insertInfo("../insurancePloicy/insert/insertInfo", {"data":jsonDate})
		 if(IsNotEmpty(m)&&m.state==0){
			 var id= _getIntOfJson(0, m, "id");
			 art.dialog({fixed:true, lock: true,content:"是否打印延保清单？",icon:'question',ok:function(){
				 toPrintSaleBill(id)
			 },cancel:true});
			 resetRoomInfo()
		}
	}else{
		alertErrorMessage("请选择车牌号")

	}
	
}



function toPrintSaleBill(id){
	window.open('printInsurancePolicy.html?id='+id)

}



function resetRoomInfo(){
	$("#Amount").val("")
	$("#Memo").val("")
	$("#license").val("")
	$("#mp").val("")
	$("#carSystem").val("")
	$("#carType").val("")
	$("#dtBegin").val("");
	$("#dtEnd").val("");
	resetMemberInfo();

}

function  __lisenseSelected(lisenseId, lisenseName,mp) {
	$("#roomNo").val(mp)
	closeLisenseListPanel()
}
</script>
<div id="memberDiv" class="hideDiv" style="display:none;">
  <div class="closeTop"><span onclick="closeParent($(this))" class="closeThe"><img src="../images/close.png"></span></div>
  <table width="100%" border="0" cellspacing="1" cellpadding="0" class="member_list">
   <!--  <caption>
    <strong>会员列表 <span id="sup">共 575 条</span></strong>
    </caption> -->
    <thead>
      <tr>
        <th>姓名</th>
        <th>手机</th>
        <th>车牌号</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody id="memberList">
    	
    </tbody>
  </table>
</div>
<div id="yinying1" style="display:none;"></div>
<div id="yinying2" style="z-index: 599"></div>
<div class="container" id="container">
  <div class="container_R fr">
    <div class="place">延保单</div> 
    <div class="member_search">
      <p><span>
        <input type="checkbox" id="shopIsChoosed" style="width:auto;height:auto;border:none;">
        店面：</span>
        <select id="shopName" onclick="openShopListPanel(this)" style=";height:20px;" disabled="disabled">
        </select>
  
        
      </p>
      </br>
      <div class="knowPerson">
        <p class="knowAll">
          <span><select id="memberSelect" style="width: 80px;" >
          	<option value="1">姓名</option>
          	<option value="2">电话</option>
          	<option value="3">车牌号</option>
          </select>：</span><label> 
            <input type="text" id="memberCardNo" class="absoluteTxt"  onkeypress="if(event.keyCode==13){searchMember()}" >
          </label>
          <input class="btn common_btn" name="查询" type="button" value="清除信息" onclick="resetMemberInfo()" >
        </p>
        <p class="knowAll">
          <label> <span>姓名：</span>
            <input type="text" readonly id="cardNo" class="memberInfo">
          </label>
          <label> <span>电话：</span>
            <input type="text" readonly id="mp" class="memberInfo">
          </label>
          <label> <span>会员级别：</span>
            <input type="text" id="levelName" readonly class="memberInfo">
          </label>
        </p>
        <p class="knowAll">
          <label> <span>车牌号：</span>
            <input type="text" readonly id="license" class="memberInfo">
          </label>
          <label> <span>车系：</span>
            <input type="text" readonly id="carSystem" class="memberInfo">
          </label>
          <label> <span>车型：</span>
            <input type="text" readonly id="carType" class="memberInfo">
          </label>
        </p>
      </div>
      <br>
      <!-- <p>
        <span>车牌号：</span>
        <input type="text" value="" id="roomNo" class="absoluteTxt">
        <input class="btn common_btn" type="button" onclick="openLisenseListPanel(this)" value="选择" >
      </p> -->
      
       <br>
			  		 <p style="padding-top: 10px; border-top: 2px solid rgb(220, 220, 220);"></p>
			  		<br>
				  	<p><label><span>延保金额：</span><input type="text" id="Amount" class="clearValue" ></label></p>
				  	<p><label><span>生效时间：</span><input type="text" id="dtBegin" class="clearValue doubledate" ></label><label><span>失效效时间：</span><input type="text" id="dtEnd" class="clearValue doubledate" ></label></p>
				  	<p><label><span>备注：</span><textarea id="Memo" class="clearValue" style="width: 500px;"></textarea></label></p>
				</form>
				<div class="BottomBtn" >
					<input id="paid_btn" class="check_btn common_btn" value="付款" type="button" >
				</div>
    </div>
    
  </div>
  <div class="fc"></div>
</div>

<!-- InstanceEndEditable --> 
<
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
addMargin($(".hideDiv"))
clearThis("absoluteTxt");
</script>
</body>
<!-- InstanceEnd -->
</html>
